let startBtn = document.querySelector('.startBtn')
let prizeCell = document.querySelectorAll('.drawBox div:not(.startBtn)')
let bb = document.querySelectorAll('.bb div')
console.log(prizeCell);
let index = 0
let targetIndex = 84
let second = 30
let a
let isRun = true
console.log(bb);
//开始抽奖
startBtn.addEventListener('click', function() {
    if (isRun) {
        isRun = false
        run()
    }
})

function run() {
    a = setTimeout(function() {
        prizeCell.forEach(function(item) {
                item.classList.remove('active')
            })
            // if (index) {
            //     prizeCell[(index - 1) % 8].classList.remove('active')
            // }
        prizeCell[index % 8].classList.add('active')
        if (index < targetIndex) {
            run()
        }
        index = gete(0, 84)
        if (second > 20 && index < 20) {
            second = second
        } else
        if (index > 60) {
            second = second
        } else {
            isRun = true
        }
    }, second)
}

function gete(min, max) {
    min = Math.ceil(min);
    max = Math.floor(max);
    return Math.floor(Math.random() * (max - min + 1)) + min; //含最大值，含最小值 
}